#coding=utf-8
'''
1.定义一个func(name)，该函数效果如下。
assert func("lilei") = "Lilei"
assert func("hanmeimei") = "Hanmeimei"
assert func("Hanmeimei") = "Hanmeimei"
'''
#capitalize()方法它返回字符串的副本，并只将其第一个字符大写
import string
def func(name):
    return  name.capitalize()

assert func("lilei") == "Lilei"
assert func("hanmeimei") == "Hanmeimei"
assert func("Hanmeimei") == "Hanmeimei"

import string
def fun2(name,callback=None):
    if callback == None:
        return name.capitalize()
    else:
        return callback(name)

assert fun2("lilei") == "Lilei"
assert fun2("LILEI",callback = string.lower) == "lilei"
assert fun2("lilei",callback = string.upper) == "LILEI"


def func3(**kargus):
    s = kargus.get('key1')
    arr = []
    for i in s:
        if isinstance(i,int):
            arr.append(i)
        elif isinstance(i,float):
            arr.append(i)
    return arr
j =  func3(key1 = [1,2,3,4,5.55,'6'])
for y in j:
    print y,


def func4(*kargs):
    s = list(kargs)
    arrs = []
    for i in s:
        if isinstance(i,str):
            arrs.append(i)
    lenx = [len(x) for x in arrs]
    if lenx:
    		min_index = min(lenx)
    		return arrs[lenx.index(min_index)]
    return None

assert func4(222,1111,'xixi','hahahah') == "xixi"
assert func4(7,'name','dasere') == 'name'
assert func4(1,2,3,4) == None

def func5(name=None,**kargs):
    lis = ["%s:%s"%(k,v) for k,v in kargs.items()]

    lis.insert(0,name)

    return ','.join(lis)


assert func5("lilei") == "lilei"
assert  func5("lilei",years=4) == "lilei,years:4"
assert func5("lilei",years=10,body_weight=20) == "lilei,body_weight:20,years:10"



